package com.guapi.util.request.impl;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.guapi.util.request.SelfRequest;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author 瓜皮哦
 */
public class ServiceRequest implements SelfRequest {
    private static final String ATTR_USER_ID="_userId";
    private static final String ATTR_ROLE_ID="_roleId";
    private static final String ATTR_COMPANY_ID="_companyId";
    private static final long serialVersionUID=1L;

    private Long userId=-1L;
    private Long roleId=-1L;
    private Long[] roleIds= {};
    private Long componyId=-1L;
    private String employeeCode;
    private String username;

    @JsonIgnore
    private Map<String,Object> attributeMap=new HashMap<>();

    @Override
    @JsonIgnore
    public void setUsername(String username) {
        this.username=username;
    }

    @Override
    @JsonIgnore
    public String getUsername() {
        return username;
    }

    @Override
    @JsonIgnore
    public Long getUserId() {
        return userId;
    }

    @Override
    @JsonIgnore
    public <T> T getAttribute(String name) {
        return (T) attributeMap.get(name);
    }

    @Override
    @JsonIgnore
    public Map<String, Object> getAttributeMap() {
        return attributeMap;
    }

    @Override
    @JsonIgnore
    public Set<String> getAttributeNames() {
        return attributeMap.keySet();
    }

    @Override
    @JsonIgnore
    public void setAttribute(String name, Object value) {
        attributeMap.put(name, value);
    }

    @Override
    @JsonIgnore
    public Long getRoleId() {
        return roleId;
    }

    @Override
    @JsonIgnore
    public void setRoleId(Long roleId) {
        this.roleId=roleId;
    }

    @Override
    @JsonIgnore
    public Long[] getAllRoleId() {
        return roleIds;
    }

    @Override
    @JsonIgnore
    public void setAllRoleId(Long[] roleIds) {
        this.roleIds=roleIds;
    }

    @Override
    @JsonIgnore
    public void setUserId(Long accountId) {
        this.userId=accountId;
    }

    @Override
    @JsonIgnore
    public String getEmployeeCode() {
        return employeeCode;
    }

    @Override
    @JsonIgnore
    public void setEmployeeCode(String employeeCode) {
        this.employeeCode=employeeCode;
    }
}
